﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Compilex.Syntatic.Declarations;
using Compilex.CodeGeneration;

namespace Compilex.Syntatic
{
    public class CommandBlock
    {
        public CodeGenerator CodeGenerator { get; set; }
        public SyntaticContext Context { get; set; }
        public IfBlock IfBlock { get; set; }
        public WhileBlock WhileBlock { get; set; }

        public CommandBlock(SyntaticContext context)
        {
            this.Context = context;
            this.CodeGenerator = new CodeGenerator(context);
            this.IfBlock = new IfBlock(context);
            this.WhileBlock = new WhileBlock(context);
        }

        public void ChildBlockEnded(CommandBlock block)
        {
            this.CodeGenerator.MergeWithChildBlock(block.CodeGenerator);
        }
    }
}
